package io.geekidea.boot.shop.controller.app;

import io.geekidea.boot.framework.page.Paging;
import io.geekidea.boot.framework.response.ApiResult;
import io.geekidea.boot.shop.query.app.AppAddressQuery;
import io.geekidea.boot.shop.service.base.api.AddressService;
import io.geekidea.boot.shop.vo.app.AppAddressVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * App收货地址 控制器
 *
 * @author geekidea
 * @since 2024-10-27
 */
@Slf4j
@RestController
@Tag(name = "App收货地址")
@RequestMapping("/app/address")
public class AppAddressController {

    @Autowired
    private AddressService addressService;

    /**
     * 获取App收货地址详情
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App收货地址详情")
    @PostMapping("/getAppAddress/{id}")
    public ApiResult<AppAddressVo> getAppAddress(@PathVariable Integer id) {
        log.info("获取App收货地址详情：{}", id);
        AppAddressVo appAddressVo = addressService.getAppAddressById(id);
        return ApiResult.success(appAddressVo);
    }

    /**
     * 获取App收货地址分页列表
     *
     * query
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App收货地址分页列表")
    @PostMapping("/getAppAddressPage")
    public ApiResult<AppAddressVo> getAppAddressPage(@Valid @RequestBody AppAddressQuery query) {
        log.info("获取App收货地址分页列表：{}", query);
        Paging<AppAddressVo> paging = addressService.getAppAddressPage(query);
        return ApiResult.success(paging);
    }

}
